package com.invengo.module_check.ui.fragment.search.item;

import androidx.annotation.NonNull;

import com.invengo.library_db.entity.module_check.BookBean;
import com.invengo.module_check.ui.fragment.search.BookAddViewModel;

import me.goldze.mvvmhabit.base.ItemViewModel;
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent;

public class BookAddItemViewModel extends ItemViewModel<BookAddViewModel> {
    public SingleLiveEvent<BookBean> book = new SingleLiveEvent<>();
    public SingleLiveEvent<Boolean> isSelect = new SingleLiveEvent<>();

    public BookAddItemViewModel(@NonNull BookAddViewModel viewModel, BookBean bean) {
        super(viewModel);
        book.postValue(bean);
        isSelect.postValue(false);
    }
    public void itemClickCommand(){
        isSelect.postValue(isSelect.getValue()?false:true);
        viewModel.itemCheckChange(book.getValue(),!isSelect.getValue());
    }
    public int getPosition() {
        return viewModel.getPosition(this) + 1;
    }

}
